package com.zdlee.netty.server20.client.console;

import com.zdlee.netty.server20.protocol.request.LoginRequestPacket;
import io.netty.channel.Channel;

import java.util.Scanner;

/**
 * @author zdlee
 * @description: ${DESCRIPTION}
 * @create 2018-12-01 13:49
 */
public class LoginConsoleCommand implements ConsoleCommand {
    @Override
    public void exec(Scanner sc, Channel channel) {
        LoginRequestPacket loginRequestPacket=new LoginRequestPacket();
        loginRequestPacket.setUserName(sc.nextLine());
        loginRequestPacket.setPassword("pwd");

        //发送登录数据包
        channel.writeAndFlush(loginRequestPacket);
        waitForLoginResponse();
    }

    private static void waitForLoginResponse(){
        try {
            Thread.sleep(1000);
        }catch (InterruptedException e)
        {

        }
    }
}
